package hadoop.ch03.v17024410134;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileStatus;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.net.URI;
import java.text.SimpleDateFormat;
import java.util.Date;

import java.text.SimpleDateFormat;

public class ReferHDFSFile {
    public static void main(String[] args) throws Exception{
        Configuration conf = new Configuration();

                URI uri = new URI("hdfs://192.168.30.131:8020");

                FileSystem fs = FileSystem.get(uri, conf, "hadoop");

                Path path = new Path("/17024410134/test5.txt");
        FileStatus fileStatus = fs.getFileLinkStatus(path);
        long blockSize = fileStatus.getBlockSize();
        System.out.println("blocksize:"+blockSize);
        long fileSize = fileStatus.getLen();
        System.out.println("filesize:"+fileSize);
        String fileOwner = fileStatus.getOwner();
        System.out.println("flleOwner"+fileOwner);
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss");
        long accessTime = fileStatus.getAccessTime();
        Date date = new Date(accessTime);
        System.out.println("accessTime"+sdf.format(date));

        long modifyTIme = fileStatus.getModificationTime();
        Date date2 = new Date(modifyTIme);
        System.out.println("modifyTime"+sdf.format(date2));

        fs.close();





    }

}
